//
//  SXTMyViewController.m
//  SXT
//
//  Created by 赵金鹏 on 16/8/9.
//  Copyright © 2016年 赵金鹏. All rights reserved.
//

#import "SXTMyViewController.h"
#import "SXTMyMessageTableView.h"//我的页面展示功能的tableview
#import "SXTMyMessageHeadView.h"//我的页面tableview顶部展示登陆注册的view
#import "SXTLandingViewController.h"//注册页面
@interface SXTMyViewController ()
/**顶部登录与注册view*/
@property (strong, nonatomic)   SXTMyMessageHeadView *headView;
/**顶部背景图片*/

@property (strong, nonatomic)   SXTMyMessageTableView *messageTable;              /** 展示功能的列表 */
@end

@implementation SXTMyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.edgesForExtendedLayout = 0;
    self.view.backgroundColor = MainColor;
    [self.view addSubview:self.headView];
    [self.view addSubview:self.messageTable];
    [self addAutoLayout];
}

- (void)addAutoLayout{
    __weak typeof (self) weakSelf = self;
    //对顶部登录注册view添加约束
    [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(weakSelf.view);
        make.height.mas_equalTo(150);
    }];
    //给tableview添加约束
    [_messageTable mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(weakSelf.view);
        make.height.mas_equalTo(176);
        make.top.equalTo(weakSelf.headView.mas_bottom).offset(35);
    }];
}

- (SXTMyMessageHeadView *)headView{
    if (!_headView) {
        _headView = [[SXTMyMessageHeadView alloc]init];
        __weak typeof (self) weakSelf = self;
        _headView.landingBlock = ^(){
            SXTLog(@"我点击了注册按钮");
            SXTLandingViewController * landing = [[SXTLandingViewController alloc]init];
            [weakSelf.navigationController pushViewController:landing animated:YES];
        };
        _headView.loginBtnBlock = ^(){
            SXTLog(@"我点击了登录按钮");
        };
    }
    return _headView;
}

- (SXTMyMessageTableView *)messageTable{
    if (!_messageTable) {
        _messageTable = [[SXTMyMessageTableView alloc]initWithFrame:CGRectMake(0, 0, 0, 0) style:(UITableViewStylePlain)];
    }
    return _messageTable;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
